package xyx.ysfwpt.controller;

import io.swagger.annotations.*;
import net.sf.json.JSONObject;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import xyx.ysfwpt.api.KdniaoTrackQueryAPI;

@Controller
@RequestMapping("/ysfwpt")
@Api(tags = {"快递鸟接口"},description = "")
public class KdniaoController {

    //可用数据
    //YTO   805274762291276021

    @ApiOperation(value = "用户登录",notes = "用户、管理员登录")
    @ApiResponses(value = { @ApiResponse(code = 200, message = "登录成功")})
    @RequestMapping(value="/logisticsInformation",method=RequestMethod.POST)
    @ResponseBody
    public JSONObject logisticsInformation(@ApiParam(value = "快递名称",required = true) @RequestParam(value = "name",required = true)String name,
                                           @ApiParam(value = "快递编号",required = true) @RequestParam(value = "id",required = true)String id){
        JSONObject jsonObject = new JSONObject();
        KdniaoTrackQueryAPI api = new KdniaoTrackQueryAPI();
        try {
            String result = api.getOrderTracesByJson(name,id);
            jsonObject.put("result",result);
        }
        catch (Exception e){
            e.printStackTrace();
        }
        return jsonObject;
    }
}